<template>
	<app-dialog ref="dialog" width="90%" :title="title" @confirm="save" confirmText="删除">
		<view style="padding: 20rpx">

			<uni-data-picker placeholder="请选择相册" popup-title="请选择相册" :localdata="dataTree" v-model="id"
				@change="onchange"></uni-data-picker>
		</view>
	</app-dialog>
</template>

<script>
	export default {
		components: {},

		data() {
			return {
				typeSelect: [],
				typeValue: null,
				title: '删除相册',
				list: [],
				dataTree: [{
						text: '我的相册',
						value: 0,
						children: []
					},
					{
						text: '魔法相册',
						value: 1,
						children: []
					}
				],
				arr1: [], ///普通相册
				arr2: [], //魔法相册
				id: '',

			};
		},

		methods: {
			onchange(e) {
				//	this.type = e.detail.value[0].value;

			},
			//  获取相册信息
			async getPhotoList() {
				let res = await this.$http.get('/app/xc/getSyXc');
				if (res.code == 0) {
					res.list.forEach((item, index) => {
						if (item.lx == 0) {
							this.arr1.push(item);
						}
						if (item.lx == 1) {
							this.arr2.push(item);
						}
					});
					this.dataTree[0].children = this.arr1.map((i) => {
						return {
							text: i.mc,
							value: i.id
						};
					});
					this.dataTree[1].children = this.arr2.map((i) => {
						return {
							text: i.mc,
							value: i.id
						};
					});
				}
			},
			
			/**
			 * 打开弹框
			 */
			/**
	
		 */
			async open() {
				this.reset();

				// 打开弹框
				await this.$refs.dialog.open();
				this.getPhotoList();
			},

			reset() {
				this.arr1 = [];
				this.arr2 = [];
				this.id = ''
			},

			// 回调参数为包含columnIndex、value、values
			confirm(e) {
				console.log('confirm', e)
				this.show = false
			},

			/**
			 * 保存
			 */
			async save() {
				try {

                     if(this.id){
						 this.showLoading('删除中')
						 await this.$http.post('/app/xc/delete', {
						 ids:this.id
						 });
 
						  this.hideLoading('删除成功')
						  this.$emit('refreshData');;
						  this.$refs.dialog.close();
					 }else{
						 this.toast('请选择要删除的相册')
					 }
					///	this.$refs.dialog.close();
					//	this.hideLoading();

				} catch (e) {
					this.errorLoading(e);
				}
			}
		}
	};
</script>

<style lang="scss" scoped>
	.auto {
		height: 980rpx;
	}
</style>